//
//  InformationViewController+Camera.m
//  NewProject
//
//  Created by admin on 2017/6/20.
//  Copyright © 2017年 李航飞. All rights reserved.
//

#import "InformationViewController+Camera.h"

@implementation InformationViewController (Camera)
- (UIImagePickerController *)imagePickerController
{
    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc]init];
    
    imagePickerController.delegate = self;
    
    return imagePickerController;
}

-(void)useCamera
{
    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        UIImagePickerController * picker = [[UIImagePickerController alloc] init];
        picker.delegate = self ;
        picker.allowsEditing = YES;
        picker.sourceType = sourceType;
        [self presentViewController:picker animated:YES completion:nil];
    }
    else
    {
        [self showTip:@"当前设备无摄像头，请从相册获取"  toView:self.view];
        self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//        [self presentViewController:self.imagePickerController animated:YES completion:nil];
    }
}

-(void)chooseFromPhoto
{
    self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentViewController:self.imagePickerController animated:YES completion:nil];
}

@end
